package org.lilred.ui;

import org.lilred.ui.theme.Theme;
import org.lilred.ui.theme.Themeable;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;

public abstract class ThemedField extends Field implements Themeable {
	Theme defaultTheme;
	Theme focusTheme;
	
	public ThemedField(Theme theme, long style) {
		this(theme, null, 0);
	}
	
	public ThemedField(Theme unfocus, Theme focus) {
		this(unfocus, focus, 0);
	}
	
	public ThemedField(Theme theme) {
		this(theme, 0);
	}
	
	public ThemedField(Theme unfocus, Theme focus, long style) {
		super(style);
		this.defaultTheme = unfocus.clone();
		this.focusTheme = focus.clone();
	}
	
	public Theme getDefaultTheme() { return defaultTheme; }
	public Theme getFocusTheme() { return focusTheme; }

	protected void paint(Graphics g) {
		if (isFocus()) focusTheme.paint(getWidth(), getHeight(), g);
		else defaultTheme.paint(getWidth(), getHeight(), g);
	}
}
